<template>
    <div>

        <input type="text" v-model="proid">
        <input type="text" v-model="num">



        <van-button square text="加入购物车" type="success" class="delete-button" @click="addCartGoods" />
    </div>
</template>



<script setup lang="ts">
// "proid": "pro_50380160-ebd6-4e68-aded-8fceefc488d1",

// userid
// : 
// "user_3f8de3d0-e224-4511-818a-315a5037fa4f"

import { useRouter } from 'vue-router'

import { ref } from 'vue'

import { cartAdd, getCartList } from '@/api/api'

const proid = ref('pro_50380160-ebd6-4e68-aded-8fceefc488d1')
const num = ref('10')

const userid = ref("user_3f8de3d0-e224-4511-818a-315a5037fa4f")

const router = useRouter()


const addCartGoods = async () => {
    let res = await cartAdd({ num: num.value, proid: proid.value, userid: userid.value })

    console.log(res)

    //  判断是不是成功
    // 成功跳转到购物车 

    router.push({ name: 'cart', query: { userid: userid.value } })


    // const dataGoods = await getCartList({ userid: userid.value })
    // console.log(dataGoods);
}
</script>

<style scoped>

</style>